<?php
class OLM_Barcode
{
	static function productNumber($product)
	{
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF('L', PDF_UNIT, array(30, 80), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(0, 0, 0);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 0);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		$pdf->SetFont('droidsansfallback', 'B', 8);
		$j = 0;
		foreach ($product as $p)
		{
			for ($i=0;$i<$p['quantity'];$i++)
			{
				$pdf->AddPage();
				$pdf->MultiCell(80, 5, $p['shelf_position'] . ' ' . $p['product_feature'], 0, 'C', 0, 1, '', 2, true);
				$pdf->write1DBarcode($p['number'], 'C128', '', '', 80, 15, 0.5, array('align' => 'C', 'text' => false, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'B');
				$pdf->MultiCell(80, 6, $p['number'] .'   '. $p['material_number'], 0, 'C', 0, 1, 0, '', true, 0, false, true, 6, 'M');
			}
		}
		$pdf->Output('pdf.pdf');
	}
	
	static function productNumberFBA($product)
	{
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF('L', PDF_UNIT, array(35, 65), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(0, 0, 0);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 0);
		$pdf->SetLanguageArray($l);
		$pdf->setCellMargins(0, 0, 0, 0);
		foreach ($product as $p)
		{
			$pdf->AddPage();
			$pdf->SetFont('droidsansfallback', 'B', 15);
			$pdf->MultiCell(65, 5, $p['number'] . '*' . $p['quantity'] . ' ' . $p['shelf_position'], 0, 'C', 0, 1, '', 9);
			$pdf->MultiCell(65, 5, $p['storage_number'], 0, 'C', 0, 0);
			for ($i=1; $i<=$p['quantity']; $i++)
			{
				$pdf->AddPage();
				$pdf->SetFont('droidsansfallback', 'B', 10);
				$pdf->write1DBarcode($p['storage_number'], 'C128', '', 3, '', 18, 0.4, array('align' => 'C', 'text' => true, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'B');
				$pdf->SetFont('droidsansfallback', '', 7);
				$pdf->MultiCell(65, 5, $p['storage_title'], 0, 'C', 0, 0, '', 27, true);
				$pdf->SetFont('droidsansfallback', '', 10);
				$pdf->MultiCell(65, 5, 'New', 0, 'L', 0, 0, 2, 30, true);
			}
		}
		$pdf->Output('pdf.pdf');
	}
	
	static function productNumberUKOverseas($product)
	{
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/config/lang/eng.php');
		require_once(Q::ini('custom_system/lib_dir') . 'tcpdf/tcpdf.php');
		$pdf = new TCPDF('L', PDF_UNIT, array(20, 96), true, 'UTF-8', false);
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
		$pdf->SetMargins(0, 2, 0);
		$pdf->SetPrintHeader(false);
		$pdf->SetPrintFooter(false);
		$pdf->SetAutoPageBreak(true, 0);
		$pdf->SetLanguageArray($l);
		$pdf->SetFont('droidsansfallback', '', 8);
		$pdf->setCellMargins(0, 0, 0, 0);
		$j = 0;
		foreach ($product as $p)
		{
			for ($i=1; $i<=$p['quantity']; $i++)
			{
				if ($j % 3 == 0)
				{
					$pdf->AddPage();
					$x = 2;
				}
				$pdf->Ln(0.5);
				$pdf->write1DBarcode($p['number'], 'C128', $x, 3, 28, 10, 0.32, array('align' => 'C', 'text' => false, 'stretchtext' => 3, 'cellfitalign' => 'C'), 'B');
				$pdf->Ln(0.5);
				$pdf->SetFont('droidsansfallback', '', 10);
				$pdf->MultiCell(28, '', $p['number'], 0, 'C', 0, 0, $x, '', true);
				$x += 32;
				$j++;
			}
		}
		$pdf->Output('pdf.pdf');
	}
}